package com.todo.strategy.online.application.backend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.strategy.online.application.backend.service.UserStrategyBackendService;
import com.todo.strategy.online.iface.backend.UserStrategyBackendIface;
import com.todo.strategy.online.iface.backend.request.*;
import com.todo.strategy.online.iface.backend.response.QueryUserStrategyByConditionResp;
import com.todo.strategy.online.iface.backend.response.UserStrategyDetailResp;
import com.todo.strategy.online.iface.backend.response.UserStrategyRelationResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/6/5 15:55
 * @description
 */
@RestController
@RequestMapping("/user/strategy")
@Tag(name = "用户攻略后台处理类", description = "用户攻略后台处理类")
public class UserStrategyBackendController implements UserStrategyBackendIface {

    @Resource
    private UserStrategyBackendService userStrategyBackendService;


    @Override
    @Operation(summary = "根据主键id查询用户攻略详情")
    @PostMapping("/queryUserStrategyDetailById")
    public BizResponse<UserStrategyDetailResp> queryUserStrategyDetailById(@RequestBody QueryUserStrategyDetailByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return userStrategyBackendService.queryUserStrategyDetailById(req);
    }

    @Override
    @Operation(summary = "多条件查询用户攻略详情")
    @PostMapping("/queryUserStrategyByCondition")
    public BizPageResponse<QueryUserStrategyByConditionResp> queryUserStrategyByCondition(@RequestBody QueryUserStrategyByConditionReq req) {
        if (req == null) {
            return BizPageResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizPageResponse.paramError("参数错误");
        }
        return userStrategyBackendService.queryUserStrategyByCondition(req);
    }

    @Override
    @Operation(summary = "查询用户攻略关联信息列表")
    @PostMapping("/queryUserStrategyRelationList")
    public BizResponse<List<UserStrategyRelationResp>> queryUserStrategyRelationList(@RequestBody QueryUserStrategyRelationListReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return userStrategyBackendService.queryUserStrategyRelationList(req);
    }

    @Override
    @Operation(summary = "禁用攻略")
    @PostMapping("/prohibitStrategyById")
    public BizResponse<Boolean> prohibitStrategyById(@RequestBody ProhibitStrategyByIdReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return userStrategyBackendService.prohibitStrategyById(req);
    }

    @Override
    @Operation(summary = "人工检测用户攻略是否通过")
    @PostMapping("/detectionUserStrategyById")
    public BizResponse<Boolean> detectionUserStrategyById(@RequestBody DetectionUserStrategyReq req) {
        if (req == null) {
            return BizResponse.paramError("参数为空");
        }
        if (!req.baseCheck()) {
            return BizResponse.paramError("参数错误");
        }
        return userStrategyBackendService.detectionUserStrategyById(req);
    }
}
